//
//  ShowsViewController.m
//  Shows
//
//  Created by Roc on 11-4-13.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "ShowsViewController.h"
#import "TopicListView.h"
#import "LocalTopicSource.h"
#import "PhotoViewController.h"

@implementation ShowsViewController

- (void)dealloc
{
    [_topicListView release];
    [_topicSource release];
    
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];

    
    LocalTopicSource* _tempTopicSource = [[LocalTopicSource alloc] init];
    if (_tempTopicSource) {
        [_tempTopicSource loadTopics];
        _topicSource = _tempTopicSource;
    }
    
    CGRect listRect = CGRectMake(268, 0, 500, 1024);
    _topicListView = [[TopicListView alloc] initWithFrame:listRect
                                              topicSource:_topicSource];
    _topicListView.topicListViewDelegate = self;
    
    [self.view addSubview:_topicListView];

}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

#pragma mark TopicViewDelegate

-(void)topicSelected:(id<Topic>)topic {
    /*NSMutableArray* photos = [NSMutableArray arrayWithObjects:
                              @"ABFJ.jpg",	@"HCMY.jpg",	@"ITGZ.jpg",
                              @"NIWB.jpg",	@"WCMA.jpg",
                              @"CQRR.jpg",	@"HGVM.jpg",	@"JFMV.jpg",
                              @"NRBR.jpg",	@"XOUS.jpg",
                              @"DZSE.jpg",	@"HJQK.jpg",	@"KNZO.jpg",
                              @"PZRD.jpg",	@"ZBAS.jpg",
                              @"EWAT.jpg",	@"HPMA.jpg",	@"MHZC.jpg",
                              @"UQYK.jpg",
                              @"GUJD.jpg",	@"HWNB.jpg",	@"MRRU.jpg",
                              @"UWZW.jpg",  nil]; 
     */
    
    //从网络获取
    NSMutableArray* photos = [NSMutableArray array];
    for(int i = 1; i <= 50; i++) {
        [photos addObject:[NSString 
                           stringWithFormat:@"http://www.yourswedding.com/photo/img/%d.jpg", i]];
    }
    PhotoViewController* controller = [[PhotoViewController alloc]
                                                initWithPhoto:photos];
    [self.navigationController pushViewController:controller animated:YES];
}

@end
